﻿/********************************************************************************/
// <copyright file="BlocksService.cs" company="Asia E-Business Solutions">
//     Copyright © 2012. All right reserved
// </copyright>
//
// <history>
//  <change who="Hieu Nguyen" date="11/12/2012 2:51:49 PM">Created</change>
// <history>
/********************************************************************************/

namespace JLL.China.Infrastructure.Services
{
    using System.Collections.Generic;
    using JLL.China.Infrastructure.Repositories;
    using JLL.China.Infrastructure.Repositories.Blocks;
    using JLL.China.Infrastructure.RepositoryFramework;
    using JLL.China.Infrastructure.UnitOfWork;
    using JLL.China.Model;

    public static  class BlocksService
    {
        private static IBlocksRepository repository;

        /// <summary>
        /// Initializes the <see cref="BlocksService"/> class.
        /// </summary>
        static BlocksService()
        {
            repository = RepositoryFactory.GetRepository<IBlocksRepository, Model.Blocks, int>(new LINQ2SQLUnitOfWork<int>());
        }

        public static void CreateBlocksItem( Blocks item)
        {
            repository.Add(item);
        }

        public static void DeteleBlocksItem(Blocks item)
        {
            repository.Remove(item);
        }

        public static void UpdateBlocksItem(Blocks item)
        {
            repository[item.ID] = item;
        }

        public static IList<Model.Blocks> Search()
        {
            return repository.Search();
        }

        public static int CountBlocksItem()
        {
            return repository.CountBlocksItem();
        }

        public static Model.Blocks FindBlocksItem(int id)
        {
            return repository.FindBy(id);
        }

        public static void CommitChanges()
        {
            repository.UnitOfWork.Commit();
        }
    }
}
